package com.zerui.manager.web;

import com.zerui.authority.annotation.Authorize;
import com.zerui.cola.dto.PageResponse;
import com.zerui.cola.dto.Response;
import com.zerui.manager.web.cmd.AccessAuthAddCmd;
import com.zerui.manager.web.cmd.AccessAuthQryCmd;
import com.zerui.manager.web.cmd.AccessAuthUpdateCmd;
import com.zerui.manager.web.vo.AccessAuthPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @Author wh
 * @create_time 2023-08-23 15:33
 */
@Validated
@Api(value = "门禁授权管理", tags = "门禁设备管理")
@RestController
@RequestMapping("/api/v1/access/auth")
@Authorize(value = {"access-control-manager:admin-auth"})
public class AccessAuthController {

    @Resource
    private AccessAuthService accessAuthService;

	@ApiOperation(value = "添加", tags = "门禁授权管理")
	@PostMapping
	public Response add(@RequestBody @Validated AccessAuthAddCmd accessAuthAddCmd) {
		return accessAuthService.add(accessAuthAddCmd);
	}

	@ApiOperation(value = "修改", tags = "门禁授权管理")
	@PutMapping
	public Response update(@RequestBody @Validated AccessAuthUpdateCmd accessAuthUpdateCmd) {
		return accessAuthService.update(accessAuthUpdateCmd);
	}

	@ApiOperation(value = "删除", tags = "门禁授权管理")
	@PostMapping("/delete/{id}")
	public Response deleteByIds(@PathVariable("id") @NotNull(message = "id不能为空") Long id) {
		return accessAuthService.deleteById(id);
	}

	@ApiOperation(value = "分页列表", tags = "门禁授权管理")
	@PostMapping("/getPageList")
	public PageResponse<AccessAuthPageVO> getPageList(@RequestBody AccessAuthQryCmd accessAuthQryCmd) {
		return accessAuthService.getPageList(accessAuthQryCmd);
	}


}
